feat: Implement multi-registry support with separate feature modules#131
Conversation
… support multiple registries
…st module and documentation updates
adriangl
left a comment
There was a problem hiding this comment.
Thanks for the effort with the PR :). However, I have a very big concern I'd like to discuss: consumer coupling.
The current implementation is built under an assumption: the project's main module imports and configures Mini and modules provide extra stores or actions for the main Mini to link. While this approach may make sense in a multi-module project, if we bundle Mini inside a library, it would require that any module consuming it must:
- Be aware that Mini is being used in the library
- Know about and explicitly instantiate the library's
Storeclasses in the module - Pass those stores to
Mini.link()
This means that if a library uses Mini internally, its consumers are forced to depend on Mini too. That breaks a fundamental principle of library design: implementation details must stay internal. A consumer of a library should just call its public API, not know or care that it uses Mini under the hood.
We have to rethink this approach before we can merge this. The main blocker that currently disallows using it with multiple modules is that we currently create a unique Mini_Generated per project, no matter the modules or libraries that it contains, and that single instance is used by the Mini code to glue everything together. In the multi-module scenario, or lib + consumer that also uses Mini the build doesn't know which Mini_Generated prevails in compilation time and breaks. We should study how to create multiple instances so each module bundles its own Mini and we don't leak it so consumers don't need to implement it to use the module or lib.
One option that comes to my mind is to generate a MiniComponent or something like that that only belongs to the module where Mini is imported, and use that class to link everything inside the module. That way we wouldn't have any issues regarding multi-module conflicts and it would keep the Mini usage as implementation detail of the module or lib, so consumers don't need to implement Mini themselves. We may keep the concept of registries to do this too.
…stead of suffixes
…into a separate consumer project
What I have implemented now is a module-local Mini runtime model:
|
… hashing fallback
By: nicolasmertanen
By: nicolasmertanen
By: DaniAguion
By: adriangl
By: adriangl
By: adriangl
PR's key points
MiniRegistryinterface and refactorsMiniclass to support multiple registries discoverysample-counter-featureandsample-message-feature) demonstrating isolated registriesMultiRegistrySampleActivityto showcase runtime linking of separate feature registriesHow to review this PR?
MiniRegistryinterface andMini.link()implementationMultiRegistrySampleActivityin the sample app to see the feature in action./gradlew :mini-processor-multiregistry-test:testRelated Issues (delete if this does not apply)
Definition of Done